﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace SkypeBot
{
    class RssStream
    {
        private string _rssUrl;

        public RssStream(string rssUrl)
        {
            _rssUrl = rssUrl;
        }

        public RssItem GetLastItem()
        {
            var document = new XmlDocument();
            document.Load(_rssUrl);
            return new RssItem(document.SelectNodes("rss/channel/item")[0]);
        }

        public IList<RssItem> GetItems()
        {
            var document = new XmlDocument();
            document.Load(_rssUrl);

            IList<RssItem> result = new List<RssItem>();
            var nodeList = document.SelectNodes("rss/channel/item");
            for (int i = 0; i < nodeList.Count; ++i )
            {
                result.Add(new RssItem(nodeList.Item(i)));
            }

            return result;
        }
    }
}
